package com.ruoyi.web.controller.share;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.share.domain.ShareTitle;
import com.ruoyi.share.domain.ShareViwepager;
import com.ruoyi.share.service.ShareTitleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/shoretitle")
public class ShareTitleController  extends BaseController {
    @Autowired
    private ShareTitleService shareTitleService;
    /**
     * 查询标题列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShareTitle shareTitle)
    {
        List<ShareTitle> list = shareTitleService.selectShareTitleList(shareTitle);
        return getDataTable(list);
    }


    /**
     * 获取标题详细信息
     */
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(shareTitleService.selectShareTitleById(id));
    }

    /**
     * 新增标题
     */
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody ShareTitle shareTitle)
    {
//        System.err.println(shareViwepager);
        return toAjax(shareTitleService.insertShareTitle(shareTitle));
    }

    /**
     * 修改标题
     */
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody ShareTitle shareTitle)
    {
        return toAjax(shareTitleService.updateShareTitle(shareTitle));
    }

    /**
     * 删除标题
     */
    @DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long ids)
    {
        return toAjax(shareTitleService.deleteShareTitleById(ids));
    }
}
